package project.euler;


/**
 * 	By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13,
 *  we can see that the 6th prime is 13.
 *  What is the 10001th prime number?
 * 
 * @author Shekhar
 *
 */
public class PE7 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		StopWatch watch = new StopWatch();
		watch.start();
		calculatePrimes();
		System.out.println("Total Time taken --> "+ watch.stop());
	}
	
	private static void calculatePrimes(){
		int number = 3;
		int primeCount = 1;
		int finalPrime = 10001;
		int primeNumber = 2;
		while(primeCount != finalPrime){
			if(isPrime(number) == true){
				primeCount++;
				primeNumber = number;
			}
			number++;
		}
		System.out.println(primeNumber);
	}

	private static boolean isPrime(int number) {
		for(int i = 2; i*i<= number;i++){
			if(number % i == 0){
				return false;
			}
		}
		return true;
	}
	
}
